package com.alisls.activiti.service.service.impl;

import com.alisls.activiti.service.entity.SysUser;
import com.alisls.activiti.service.mapper.SysUserMapper;
import com.alisls.activiti.service.service.SysUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * 系统用户服务
 *
 * @author Ke Wang
 */
@Service
@Slf4j
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    /**
     * 根据用户名查询用户
     * @param username 用户名
     * @return 用户
     */
    @Override
    public SysUser getByUsername(String username) {
        if (!StringUtils.hasLength(username)) {
            return null;
        }
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        return baseMapper.selectOne(queryWrapper);
    }

}
